import AssistantMain from './components/assistantMain'
export default {
  install(app, options) {
    // '教育问答','智能出题','图片理解','体育指导','文字润色'
    const getAbilities = options?.abilities ? options.abilities : ["QAndA","setQuestion","imageComprehension","athleticDirector","textPolishing"];
    const abilitiesParam = {
      QAndA:{
        id:1,
        name:"教育问答"
      },
      setQuestion:{
        id:2,
        name:"智能出题"
      },
      imageComprehension:{
        id:3,
        name:"图片理解"
      },
      athleticDirector:{
        id:4,
        name:"体育指导"
      },
      textPolishing:{
        id:5,
        name:"文字润色"
      },
    }
    let abilitiesArray = [];
    getAbilities.forEach(item => {
      abilitiesArray.push(abilitiesParam[item]);
    });
   

    app.component('AssistantMain', AssistantMain)
    if (app.config && app.config.globalProperties) {
      console.log('Detected Vue 3.x')
      app.config.globalProperties.$assistantAbilities = [].concat(abilitiesArray);

      app.config.globalProperties.$isShowAssistant =  (flag) => {
        console.log("options.id",options.id);
        document.getElementById(options.id).style.position = "relative";
        document.getElementById(options.id).style.height = "100%";
      flag ? document.getElementById(options.id).style.marginRight = "400px" : document.getElementById(options.id).style.marginRight = "0px" 
      }
    } else if (typeof app === 'function' && app.version && app.version.startsWith('2.')) {
      console.log('Detected Vue 2.x')
      app.prototype.$assistantAbilities = [].concat(abilitiesArray);
      app.prototype.$isShowAssistant =  (flag) => {
        console.log("options.id",options.id);
        document.getElementById(options.id).style.position = "relative";
        document.getElementById(options.id).style.height = "100%";
      flag ? document.getElementById(options.id).style.marginRight = "400px" : document.getElementById(options.id).style.marginRight = "0px" 
      }
    } else {
      console.error('Unsupported Vue version. This plugin supports Vue 2 and Vue 3.')
    }
  }
}
